#include <stdio.h>

int main(void)
{
    char old_name[100] = {0};
    char new_name[100] = {0};
    char *s = old_name;
    int ret = 0;

    printf("please input rename path/filename:\n");
    scanf("%s", old_name);
    printf("old_name=%s\n", old_name);

    FILE *fp = fopen(old_name, "r+");
    if(fp == NULL)
    {
        perror("fopen fail");
        return -1;
    }
    else
    {
        printf("open file successfull!\n");
        fclose(fp);
        printf("please input new path/name:\n");
        scanf("%s", new_name);
        printf("new name:%s\n", new_name);
        ret = rename(old_name, new_name);
        if(ret == 0)
        {
            printf("rename %s file success!\n", new_name);
        }
    }
    return 0;
}